package json;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections4.CollectionUtils;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author: youdao.hww
 * @Date: 7/24/24
 * @Desc:
 */
public class Test {
    public static void main(String[] args) throws IllegalAccessException {



        String str3="[\n" +
                "{\n" +
                "\"aliasCode\": \"4\",\n" +
                "\"amount\": 268,\n" +
                "\"billDetailSummaryWithChargeItem\": [],\n" +
                "\"discountAmount\": 0,\n" +
                "\"selfArrangedAmount\": 0,\n" +
                "\"selfExpensedAmount\": 268,\n" +
                "\"subjectCode\": \"20240122660180\",\n" +
                "\"subjectName\": \"其他费用\"\n" +
                "},\n" +
                "{\n" +
                "\"aliasCode\": \"1\",\n" +
                "\"amount\": 4006,\n" +
                "\"billDetailSummaryWithChargeItem\": [],\n" +
                "\"discountAmount\": 0,\n" +
                "\"selfArrangedAmount\": 0,\n" +
                "\"selfExpensedAmount\": 309,\n" +
                "\"subjectCode\": \"20240122281658\",\n" +
                "\"subjectName\": \"一般医疗服务费\"\n" +
                "},\n" +
                "{\n" +
                "\"aliasCode\": \"24\",\n" +
                "\"amount\": 435.23,\n" +
                "\"billDetailSummaryWithChargeItem\": [],\n" +
                "\"discountAmount\": 0,\n" +
                "\"selfArrangedAmount\": -0.19,\n" +
                "\"selfExpensedAmount\": 0,\n" +
                "\"subjectCode\": \"20240122344226\",\n" +
                "\"subjectName\": \"治疗用一次性医用材料费\"\n" +
                "},\n" +
                "{\n" +
                "\"aliasCode\": \"2\",\n" +
                "\"amount\": 817.9,\n" +
                "\"billDetailSummaryWithChargeItem\": [],\n" +
                "\"discountAmount\": 0,\n" +
                "\"selfArrangedAmount\": 0,\n" +
                "\"selfExpensedAmount\": 0,\n" +
                "\"subjectCode\": \"20240122813731\",\n" +
                "\"subjectName\": \"一般治疗操作费\"\n" +
                "},\n" +
                "{\n" +
                "\"aliasCode\": \"15.1\",\n" +
                "\"amount\": 11.44,\n" +
                "\"billDetailSummaryWithChargeItem\": [],\n" +
                "\"discountAmount\": 0,\n" +
                "\"selfArrangedAmount\": 0.22,\n" +
                "\"selfExpensedAmount\": 0,\n" +
                "\"subjectCode\": \"20240808483552\",\n" +
                "\"subjectName\": \"抗菌药物\"\n" +
                "},\n" +
                "{\n" +
                "\"aliasCode\": \"3\",\n" +
                "\"amount\": 1456,\n" +
                "\"billDetailSummaryWithChargeItem\": [],\n" +
                "\"discountAmount\": 0,\n" +
                "\"selfArrangedAmount\": 0,\n" +
                "\"selfExpensedAmount\": 0,\n" +
                "\"subjectCode\": \"20240122215457\",\n" +
                "\"subjectName\": \"护理费\"\n" +
                "},\n" +
                "{\n" +
                "\"aliasCode\": \"6\",\n" +
                "\"amount\": 2684,\n" +
                "\"billDetailSummaryWithChargeItem\": [],\n" +
                "\"discountAmount\": 0,\n" +
                "\"selfArrangedAmount\": 0,\n" +
                "\"selfExpensedAmount\": 165,\n" +
                "\"subjectCode\": \"20240122041234\",\n" +
                "\"subjectName\": \"实验室诊断费\"\n" +
                "},\n" +
                "{\n" +
                "\"aliasCode\": \"16\",\n" +
                "\"amount\": 90.05,\n" +
                "\"billDetailSummaryWithChargeItem\": [],\n" +
                "\"discountAmount\": 0,\n" +
                "\"selfArrangedAmount\": 1.56,\n" +
                "\"selfExpensedAmount\": 0,\n" +
                "\"subjectCode\": \"20240122058131\",\n" +
                "\"subjectName\": \"中成药费\"\n" +
                "},\n" +
                "{\n" +
                "\"aliasCode\": \"15\",\n" +
                "\"amount\": 2602.41,\n" +
                "\"billDetailSummaryWithChargeItem\": [],\n" +
                "\"discountAmount\": 0,\n" +
                "\"selfArrangedAmount\": 30.13,\n" +
                "\"selfExpensedAmount\": 24.24,\n" +
                "\"subjectCode\": \"20240122101277\",\n" +
                "\"subjectName\": \"西药费\"\n" +
                "},\n" +
                "{\n" +
                "\"aliasCode\": \"23\",\n" +
                "\"amount\": 5.05,\n" +
                "\"billDetailSummaryWithChargeItem\": [],\n" +
                "\"discountAmount\": 0,\n" +
                "\"selfArrangedAmount\": 0,\n" +
                "\"selfExpensedAmount\": 0,\n" +
                "\"subjectCode\": \"20240122127670\",\n" +
                "\"subjectName\": \"检查用一次性医用材料费\"\n" +
                "},\n" +
                "{\n" +
                "\"aliasCode\": \"17\",\n" +
                "\"amount\": 915.43,\n" +
                "\"billDetailSummaryWithChargeItem\": [],\n" +
                "\"discountAmount\": 0,\n" +
                "\"selfArrangedAmount\": 0,\n" +
                "\"selfExpensedAmount\": 0,\n" +
                "\"subjectCode\": \"20240122323588\",\n" +
                "\"subjectName\": \"中草药费\"\n" +
                "},\n" +
                "{\n" +
                "\"aliasCode\": \"13\",\n" +
                "\"amount\": 297,\n" +
                "\"billDetailSummaryWithChargeItem\": [],\n" +
                "\"discountAmount\": 0,\n" +
                "\"selfArrangedAmount\": 0,\n" +
                "\"selfExpensedAmount\": 0,\n" +
                "\"subjectCode\": \"20240122400022\",\n" +
                "\"subjectName\": \"中医治疗费\"\n" +
                "},\n" +
                "{\n" +
                "\"aliasCode\": \"7\",\n" +
                "\"amount\": 649,\n" +
                "\"billDetailSummaryWithChargeItem\": [],\n" +
                "\"discountAmount\": 0,\n" +
                "\"selfArrangedAmount\": 40.7,\n" +
                "\"selfExpensedAmount\": 30,\n" +
                "\"subjectCode\": \"20240122268881\",\n" +
                "\"subjectName\": \"影像学诊断费\"\n" +
                "}\n" +
                "]";


        List<BillDetailSummaryWithSubjectDTO> str3Summary = JSONArray.parseArray(str3, BillDetailSummaryWithSubjectDTO.class);
        BigDecimal str3SummaryAmount = str3Summary.stream().map(BillDetailSummaryWithSubjectDTO::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
        System.out.println("str3SummaryAmount = " + str3SummaryAmount);
    }



    public static Map<String, Object> objectToMap(Object obj) throws IllegalAccessException {
        Map<String, Object> map = new HashMap<>();
        Class<?> clazz = obj.getClass();
        for (Field field : clazz.getDeclaredFields()) {
            field.setAccessible(true);
            map.put(field.getName(), field.get(obj));
        }
        return map;
    }




    private static FeeInformation   buildSubjectGroup(FeeInformation feeInformation, List<BillDetailSummaryWithSubjectDTO> billDetailSummaryWithSubjectDTOS) {
        Map<String, BigDecimal> feeMap = billDetailSummaryWithSubjectDTOS
                .stream().filter(subjectDTO -> subjectDTO.getAliasCode() != null)
                .filter(subjectDTO -> subjectDTO.getAmount() != null)
                .collect(Collectors.toMap(BillDetailSummaryWithSubjectDTO::getAliasCode, BillDetailSummaryWithSubjectDTO::getAmount));

        //综合医疗服务类
        /*1:4575*/
        feeInformation.setGeneralMedicalServiceFee(feeMap.get(EMedicalFeeTypeEnum.GENERAL_MEDICAL_SERVICE_FEE.getCode()));
        feeInformation.setTcmDiaTreatFee(feeMap.get(EMedicalFeeTypeEnum.GENERAL_MEDICAL_SERVICE_FEE_1.getCode()));
        feeInformation.setTcmConsultationFee(feeMap.get(EMedicalFeeTypeEnum.GENERAL_MEDICAL_SERVICE_FEE_2.getCode()));
        //一般医疗服务费 = 一般医疗服务费 + 中医辨证论治费 + 中医辨证论治会诊费
        feeInformation.setGeneralMedicalServiceFee(addFee(feeInformation.getGeneralMedicalServiceFee(),
                Arrays.asList(feeInformation.getTcmDiaTreatFee(), feeInformation.getTcmConsultationFee())));
        /*2,3,4: 1093.6+598+56*/
        feeInformation.setGeneralTreatmentFee(feeMap.get(EMedicalFeeTypeEnum.GENERAL_TREATMENT_FEE.getCode()));
        feeInformation.setNursingFee(feeMap.get(EMedicalFeeTypeEnum.NURSING_FEE.getCode()));
        feeInformation.setOtherComprehensiveFee(feeMap.get(EMedicalFeeTypeEnum.OTHER_COMPREHENSIVE_FEE.getCode()));

        /*6,7,8  1263+1069+277*/
        //诊断类
        feeInformation.setPathologicalDiagnosisFee(feeMap.get(EMedicalFeeTypeEnum.PATHOLOGICAL_DIAGNOSIS_FEE.getCode()));
        feeInformation.setLaboratoryDiagnosisFee(feeMap.get(EMedicalFeeTypeEnum.LABORATORY_DIAGNOSIS_FEE.getCode()));
        feeInformation.setImagingDiagnosisFee(feeMap.get(EMedicalFeeTypeEnum.IMAGING_DIAGNOSIS_FEE.getCode()));
        feeInformation.setClinicalDiagnosisProjectFee(feeMap.get(EMedicalFeeTypeEnum.CLINICAL_DIAGNOSIS_PROJECT_FEE.getCode()));


        /*9.1,10.1:  132+846*/
        //治疗类
        feeInformation.setNonSurgicalTreatmentFee(feeMap.get(EMedicalFeeTypeEnum.NON_SURGICAL_TREATMENT_FEE.getCode()));
        feeInformation.setClinicalPhysicalTherapyFee(feeMap.get(EMedicalFeeTypeEnum.CLINICAL_PHYSICAL_THERAPY_FEE.getCode()));

        feeInformation.setOperationTreatmentFee(feeMap.get(EMedicalFeeTypeEnum.OPERATION_TREATMENT_FEE.getCode()));
        feeInformation.setAnesthesiaFee(feeMap.get(EMedicalFeeTypeEnum.ANESTHESIA_FEE.getCode()));
        feeInformation.setOperationFee(feeMap.get(EMedicalFeeTypeEnum.OPERATION_FEE.getCode()));

        // 手术治疗费 = 手术治疗费 + 麻醉费 + 手术费
        feeInformation.setOperationTreatmentFee(addFee(feeInformation.getOperationTreatmentFee(),
                Arrays.asList(feeInformation.getAnesthesiaFee(), feeInformation.getOperationFee())));

        /*11*/
        //康复类
        feeInformation.setRehabilitationFee(feeMap.get(EMedicalFeeTypeEnum.REHABILITATION_FEE.getCode()));

        /*13: 1188*/
        //中医类（中医和民族医医疗服务）
        feeInformation.setTcmConsultation(feeMap.get(EMedicalFeeTypeEnum.TCM_TREATMENT_DIAG_FEE.getCode()));
        feeInformation.setTcmTreatmentFee(feeMap.get(EMedicalFeeTypeEnum.TCM_TREATMENT_FEE.getCode()));
        feeInformation.setTcmExternalTreatment(feeMap.get(EMedicalFeeTypeEnum.TCM_TREATMENT_FEE_1.getCode()));
        feeInformation.setTcmBoneFracture(feeMap.get(EMedicalFeeTypeEnum.TCM_TREATMENT_FEE_2.getCode()));
        feeInformation.setAcupunctureAcupuncture(feeMap.get(EMedicalFeeTypeEnum.TCM_TREATMENT_FEE_3.getCode()));
        feeInformation.setTcmTherapy(feeMap.get(EMedicalFeeTypeEnum.TCM_TREATMENT_FEE_4.getCode()));
        feeInformation.setTcmAnorectumTreat(feeMap.get(EMedicalFeeTypeEnum.TCM_TREATMENT_FEE_5.getCode()));
        feeInformation.setTcmSpecialTreat(feeMap.get(EMedicalFeeTypeEnum.TCM_TREATMENT_FEE_6.getCode()));
        feeInformation.setOtherTcm(feeMap.get(EMedicalFeeTypeEnum.TCM_OTHER_FEE.getCode()));
        feeInformation.setTcmSpecialProcess(feeMap.get(EMedicalFeeTypeEnum.TCM_OTHER_FEE_01.getCode()));
        feeInformation.setDialecticalBid(feeMap.get(EMedicalFeeTypeEnum.TCM_OTHER_FEE_02.getCode()));

        // 中医治疗 = 中医治疗 + 中医外治 + 中医骨伤 + 针刺与炙法 + 中医推拿治疗 + 中医肛肠治疗 + 中医特殊治疗
        feeInformation.setTcmTreatmentFee(addFee(feeInformation.getTcmTreatmentFee(),
                Arrays.asList(feeInformation.getTcmExternalTreatment(), feeInformation.getTcmBoneFracture(),
                        feeInformation.getAcupunctureAcupuncture(), feeInformation.getTcmTherapy(),
                        feeInformation.getTcmAnorectumTreat(), feeInformation.getTcmSpecialTreat())));

        // 中医其他 = 中医其他 + 中药特殊调配加工 + 辨证施膳
        feeInformation.setOtherTcm(addFee(feeInformation.getOtherTcm(),
                Arrays.asList(feeInformation.getTcmSpecialProcess(), feeInformation.getDialecticalBid())));

        //西药类
        /*15,15,1: 1408.49+421.12*/
        feeInformation.setWesternMedicineFee(feeMap.get(EMedicalFeeTypeEnum.WESTERN_MEDICINE_FEE.getCode()));
        feeInformation.setAntibioticsFee(feeMap.get(EMedicalFeeTypeEnum.ANTIBIOTICS_FEE.getCode()));
        // 西药费 = 西药费 + 抗菌药物费
        feeInformation.setWesternMedicineFee(addFee(feeInformation.getWesternMedicineFee(),
                Collections.singletonList(feeInformation.getAntibioticsFee())));

        //中药类
        feeInformation.setChineseMedicineFee(feeMap.get(EMedicalFeeTypeEnum.CHINESE_MEDICINE_FEE.getCode()));
        feeInformation.setHerbaPreparationFee(feeMap.get(EMedicalFeeTypeEnum.HERBAL_MEDICINE_FEE.getCode()));
        feeInformation.setHerbalMedicineFee(feeMap.get(EMedicalFeeTypeEnum.CHINESE_HERBAL_MEDICINE_FEE.getCode()));
        // 中药费 = 中药费 + 医疗机构中药制剂费
        feeInformation.setChineseMedicineFee(addFee(feeInformation.getChineseMedicineFee(),
                Collections.singletonList(feeInformation.getHerbaPreparationFee())));

        //血液和血液制品类
        feeInformation.setBloodTransfusionFee(feeMap.get(EMedicalFeeTypeEnum.BLOOD_FEE.getCode()));
        feeInformation.setAlbuminProductsFee(feeMap.get(EMedicalFeeTypeEnum.ALBUMIN_PRODUCTS_FEE.getCode()));
        feeInformation.setGlobulinProductsFee(feeMap.get(EMedicalFeeTypeEnum.GLOBULIN_PRODUCTS_FEE.getCode()));
        feeInformation.setCoagulationFactorProductsFee(feeMap.get(EMedicalFeeTypeEnum.COAGULATION_FACTOR_PRODUCTS_FEE.getCode()));
        feeInformation.setCytokineProductsFee(feeMap.get(EMedicalFeeTypeEnum.CYTOKINE_PRODUCTS_FEE.getCode()));

        /*24,25: 156.62+690.98*/
        //耗材类
        feeInformation.setExaminationDisposableMedicalMaterialsFee(feeMap.get(EMedicalFeeTypeEnum.EXAMINATION_DISPOSABLE_MEDICAL_MATERIALS_FEE.getCode()));
        feeInformation.setTreatmentDisposableMedicalMaterialsFee(feeMap.get(EMedicalFeeTypeEnum.TREATMENT_DISPOSABLE_MEDICAL_MATERIALS_FEE.getCode()));
        feeInformation.setOperationDisposableMedicalMaterialsFee(feeMap.get(EMedicalFeeTypeEnum.OPERATION_DISPOSABLE_MEDICAL_MATERIALS_FEE.getCode()));
        /*26: 1181.6*/
        feeInformation.setOtherFee(feeMap.get(EMedicalFeeTypeEnum.OTHER_FEE.getCode()));

        //总费用
        BigDecimal totalAmount = billDetailSummaryWithSubjectDTOS.stream().map(BillDetailSummaryWithSubjectDTO::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
        BigDecimal totalSelfArrangedAmount = billDetailSummaryWithSubjectDTOS.stream().map(BillDetailSummaryWithSubjectDTO::getSelfArrangedAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
        BigDecimal totalSelfExpensedAmount = billDetailSummaryWithSubjectDTOS.stream().map(BillDetailSummaryWithSubjectDTO::getSelfExpensedAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
        feeInformation.setTotalHospitalizationFee(totalAmount);
        //自付费用等于自理费用+自费费用
        feeInformation.setSelfFee(totalSelfExpensedAmount.add(totalSelfArrangedAmount));
        return feeInformation;
    }





    private static BigDecimal addFee(BigDecimal fee, List<BigDecimal> asList) {
        BigDecimal calFee = BigDecimal.ZERO;
        for (BigDecimal b : asList) {
            if (b != null) {
                calFee = calFee.add(b).setScale(2, RoundingMode.HALF_UP);
            }
        }
        if (fee != null) {
            calFee = calFee.add(fee).setScale(2, RoundingMode.HALF_UP);
        }
        if (calFee.compareTo(BigDecimal.ZERO) != 0) {
            return calFee;
        }
        return null;
    }




    //合并相同的病案首页
    public static List<BillDetailSummaryWithSubjectDTO> mergeSummarySubject(List<String> sameBizCodes,
                                                                      List<BillDetailSummaryWithSubjectDTO> transferBillDetailSummary, List<BillDetailSummaryWithSubjectDTO> originalBillDetailSummary) {
        /*割接费用中相同的病案首页*/
        List<BillDetailSummaryWithSubjectDTO> sameTransferBillDetailSummary = transferBillDetailSummary.stream()
                .filter(item -> sameBizCodes.contains(item.getSubjectCode())).collect(Collectors.toList());
        /*原始病案首页相同的病案首页*/
        List<BillDetailSummaryWithSubjectDTO> sameOriginalBillDetailSummary = originalBillDetailSummary.stream()
                .filter(item -> sameBizCodes.contains(item.getSubjectCode())).collect(Collectors.toList());
        /*合并后的病案首页*/
        List<BillDetailSummaryWithSubjectDTO> mergeListDetails = new ArrayList<>();
        //循环割接费用的病案首页
        for (BillDetailSummaryWithSubjectDTO one : sameTransferBillDetailSummary) {
            if (one.getSubjectCode().equals("20240122101277")){
                //找到原始的病案首页
                BillDetailSummaryWithSubjectDTO two = sameOriginalBillDetailSummary.stream().filter(item -> item
                        .getSubjectCode().equals(one.getSubjectCode())).findAny().orElse(null);
                //合并
                if (Objects.nonNull(two) && CollectionUtils.isNotEmpty(two.getBillDetailSummaryWithChargeItem())) {
                    //合并明细
                    one.getBillDetailSummaryWithChargeItem().addAll(two.getBillDetailSummaryWithChargeItem());
                    List<BillDetailSummaryWithChargeItemDTO> totalBillDetailSummaryWithChargeItems = one.getBillDetailSummaryWithChargeItem();
                    //3、重新算总金额
                    BigDecimal subjectTotalAmount = totalBillDetailSummaryWithChargeItems.stream()
                            .map(BillDetailSummaryWithChargeItemDTO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
                    // 总额是0的科目不展示在病案首页
                    if (subjectTotalAmount.compareTo(BigDecimal.ZERO) > 0) {
                        BillDetailSummaryWithSubjectDTO newDetailSummaryWithSubject = new BillDetailSummaryWithSubjectDTO();
                        newDetailSummaryWithSubject.setSubjectCode(two.getSubjectCode());
                        newDetailSummaryWithSubject.setAliasCode(two.getAliasCode());
                        newDetailSummaryWithSubject.setSubjectName(two.getSubjectName());
                        newDetailSummaryWithSubject.setAmount(totalBillDetailSummaryWithChargeItems.stream()
                                .map(BillDetailSummaryWithChargeItemDTO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP));
                        newDetailSummaryWithSubject.setDiscountAmount(BigDecimal.ZERO);
                        newDetailSummaryWithSubject.setSelfArrangedAmount(totalBillDetailSummaryWithChargeItems.stream()
                                .map(BillDetailSummaryWithChargeItemDTO::getSelfArrangedAmount).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP));
                        newDetailSummaryWithSubject.setSelfExpensedAmount(totalBillDetailSummaryWithChargeItems.stream()
                                .map(BillDetailSummaryWithChargeItemDTO::getSelfExpensedAmount).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP));
                        newDetailSummaryWithSubject.setBillDetailSummaryWithChargeItem(totalBillDetailSummaryWithChargeItems);
                        //2、分组添加：添加返回对象到结果集合
                        mergeListDetails.add(newDetailSummaryWithSubject);
                    }
                }
            }
        }
        return mergeListDetails;
    }









    public static List<BillDetailSummaryWithSubjectDTO> transferPage() {
        String string = "[{\"aliasCode\":\"4\",\"amount\":40,\"billDetailSummaryWithChargeItem\":[{\"amount\":40,\"chargeItemName\":\"计算机图文报告\",\"chargeItemType\":\"FH0173.02\",\"price\":8,\"quantity\":5,\"selfArrangedAmount\":0,\"selfExpensedAmount\":40,\"selfPaidAmount\":40}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":40,\"subjectCode\":\"20240122660180\",\"subjectName\":\"其他费用\"},{\"aliasCode\":\"8\",\"amount\":277,\"billDetailSummaryWithChargeItem\":[{\"amount\":42,\"chargeItemName\":\"血氧饱和度监测/小时\",\"chargeItemType\":\"FH0173.02\",\"price\":2,\"quantity\":21,\"selfArrangedAmount\":0,\"selfExpensedAmount\":42,\"selfPaidAmount\":42},{\"amount\":130,\"chargeItemName\":\"脓肿切开引流术/次\",\"chargeItemType\":\"FH0173.02\",\"price\":130,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":130,\"selfPaidAmount\":130},{\"amount\":105,\"chargeItemName\":\"心电监护/小时\",\"chargeItemType\":\"FH0173.02\",\"price\":5,\"quantity\":21,\"selfArrangedAmount\":0,\"selfExpensedAmount\":105,\"selfPaidAmount\":105}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":277,\"subjectCode\":\"20240122488314\",\"subjectName\":\"临床诊断项目费用\"},{\"aliasCode\":\"7\",\"amount\":829,\"billDetailSummaryWithChargeItem\":[{\"amount\":70,\"chargeItemName\":\"浅表彩超检查(体表包块）\",\"chargeItemType\":\"FH0173.02\",\"price\":70,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":70,\"selfPaidAmount\":70},{\"amount\":60,\"chargeItemName\":\"颈部血管彩色多普勒超声\",\"chargeItemType\":\"FH0173.02\",\"price\":60,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":60,\"selfPaidAmount\":60},{\"amount\":20,\"chargeItemName\":\"膀胱残余尿量测定\",\"chargeItemType\":\"FH0173.02\",\"price\":20,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":20,\"selfPaidAmount\":20},{\"amount\":240,\"chargeItemName\":\"四肢血管彩色多普勒超声\",\"chargeItemType\":\"FH0173.02\",\"price\":60,\"quantity\":4,\"selfArrangedAmount\":0,\"selfExpensedAmount\":240,\"selfPaidAmount\":240},{\"amount\":90,\"chargeItemName\":\"16层及以上多排螺旋CT加收\",\"chargeItemType\":\"FH0173.02\",\"price\":45,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":90,\"selfPaidAmount\":90},{\"amount\":65,\"chargeItemName\":\"心脏彩色多普勒超声\",\"chargeItemType\":\"FH0173.02\",\"price\":65,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":65,\"selfPaidAmount\":65},{\"amount\":50,\"chargeItemName\":\"左心功能测定\",\"chargeItemType\":\"FH0173.02\",\"price\":50,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":50,\"selfPaidAmount\":50},{\"amount\":234,\"chargeItemName\":\"螺旋CT平扫（一个部位）\",\"chargeItemType\":\"FH0173.02\",\"price\":117,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":234,\"selfPaidAmount\":234}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":829,\"subjectCode\":\"20240122268881\",\"subjectName\":\"影像学诊断费\"},{\"aliasCode\":\"25\",\"amount\":690.98,\"billDetailSummaryWithChargeItem\":[{\"amount\":292.98,\"chargeItemName\":\"可吸收性外科缝线2-0 VCA24D46/包\",\"chargeItemType\":\"FH0173.03\",\"price\":292.98,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":292.98,\"selfPaidAmount\":292.98},{\"amount\":398,\"chargeItemName\":\"创伤引流套装(正负压型：C型-R-14F-200/700/套\",\"chargeItemType\":\"FH0173.03\",\"price\":398,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":398,\"selfPaidAmount\":398}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":690.98,\"subjectCode\":\"20240122854051\",\"subjectName\":\"手术用一次性医用材料费\"},{\"aliasCode\":\"1\",\"amount\":1671,\"billDetailSummaryWithChargeItem\":[{\"amount\":4,\"chargeItemName\":\"陪客躺椅费/日\",\"chargeItemType\":\"FH0173.02\",\"price\":2,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":4,\"selfPaidAmount\":4},{\"amount\":40,\"chargeItemName\":\"空调费/天\",\"chargeItemType\":\"FH0173.02\",\"price\":20,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":40,\"selfPaidAmount\":40},{\"amount\":5,\"chargeItemName\":\"静脉血栓风险评估与出血风险评估/次\",\"chargeItemType\":\"FH0173.02\",\"price\":5,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":5,\"selfPaidAmount\":5},{\"amount\":50,\"chargeItemName\":\"空调费/天\",\"chargeItemType\":\"FH0173.02\",\"price\":10,\"quantity\":5,\"selfArrangedAmount\":0,\"selfExpensedAmount\":50,\"selfPaidAmount\":50},{\"amount\":880,\"chargeItemName\":\"床位费/天\",\"chargeItemType\":\"FH0173.02\",\"price\":220,\"quantity\":4,\"selfArrangedAmount\":0,\"selfExpensedAmount\":880,\"selfPaidAmount\":880},{\"amount\":250,\"chargeItemName\":\"床位费/天\",\"chargeItemType\":\"FH0173.02\",\"price\":50,\"quantity\":5,\"selfArrangedAmount\":0,\"selfExpensedAmount\":250,\"selfPaidAmount\":250},{\"amount\":200,\"chargeItemName\":\"床位费/天\",\"chargeItemType\":\"FH0173.02\",\"price\":100,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":200,\"selfPaidAmount\":200},{\"amount\":242,\"chargeItemName\":\"住院诊查费（二级医院）/日\",\"chargeItemType\":\"FH0173.02\",\"price\":22,\"quantity\":11,\"selfArrangedAmount\":0,\"selfExpensedAmount\":242,\"selfPaidAmount\":242}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":1671,\"subjectCode\":\"20240122281658\",\"subjectName\":\"一般医疗服务费\"},{\"aliasCode\":\"3\",\"amount\":286,\"billDetailSummaryWithChargeItem\":[{\"amount\":286,\"chargeItemName\":\"等级护理（二级医院）/日\",\"chargeItemType\":\"FH0173.02\",\"price\":26,\"quantity\":11,\"selfArrangedAmount\":0,\"selfExpensedAmount\":286,\"selfPaidAmount\":286}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":286,\"subjectCode\":\"20240122215457\",\"subjectName\":\"护理费\"},{\"aliasCode\":\"6\",\"amount\":1263,\"billDetailSummaryWithChargeItem\":[{\"amount\":23,\"chargeItemName\":\"血清淀粉样蛋白测定(SAA)/项\",\"chargeItemType\":\"FH0173.02\",\"price\":23,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":23,\"selfPaidAmount\":23},{\"amount\":18,\"chargeItemName\":\"尿常规/次\",\"chargeItemType\":\"FH0173.02\",\"price\":18,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":18,\"selfPaidAmount\":18},{\"amount\":15,\"chargeItemName\":\"乙肝表面抗原测定(HBsAg)/项\",\"chargeItemType\":\"FH0173.02\",\"price\":15,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":15,\"selfPaidAmount\":15},{\"amount\":3,\"chargeItemName\":\"粪便常规/次\",\"chargeItemType\":\"FH0173.02\",\"price\":3,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":3,\"selfPaidAmount\":3},{\"amount\":8,\"chargeItemName\":\"血清前白蛋白测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":8,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":8,\"selfPaidAmount\":8},{\"amount\":3,\"chargeItemName\":\"粪便隐血试验（OB）/次\",\"chargeItemType\":\"FH0173.02\",\"price\":3,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":3,\"selfPaidAmount\":3},{\"amount\":5,\"chargeItemName\":\"不加热血清反应素试验/项\",\"chargeItemType\":\"FH0173.02\",\"price\":5,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":5,\"selfPaidAmount\":5},{\"amount\":15,\"chargeItemName\":\"血常规（五分类）/次\",\"chargeItemType\":\"FH0173.02\",\"price\":15,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":15,\"selfPaidAmount\":15},{\"amount\":30,\"chargeItemName\":\"抗甲状腺球蛋白抗体测定(TGAb)/项\",\"chargeItemType\":\"FH0173.02\",\"price\":30,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":30,\"selfPaidAmount\":30},{\"amount\":16,\"chargeItemName\":\"血清β-羟基丁酸测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":16,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":16,\"selfPaidAmount\":16},{\"amount\":8,\"chargeItemName\":\"Rh血型鉴定/次\",\"chargeItemType\":\"FH0173.02\",\"price\":8,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":8,\"selfPaidAmount\":8},{\"amount\":8,\"chargeItemName\":\"ABO血型鉴定/次\",\"chargeItemType\":\"FH0173.02\",\"price\":8,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":8,\"selfPaidAmount\":8},{\"amount\":170,\"chargeItemName\":\"血栓弹力图试验（TEG）/次\",\"chargeItemType\":\"FH0173.02\",\"price\":170,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":170,\"selfPaidAmount\":170},{\"amount\":50,\"chargeItemName\":\"血浆D-二聚体测定 (D-Dimer)/项\",\"chargeItemType\":\"FH0173.02\",\"price\":50,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":50,\"selfPaidAmount\":50},{\"amount\":120,\"chargeItemName\":\"B型纳尿肽定量测定（BNT）/项\",\"chargeItemType\":\"FH0173.02\",\"price\":120,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":120,\"selfPaidAmount\":120},{\"amount\":15,\"chargeItemName\":\"电解质测定/次\",\"chargeItemType\":\"FH0173.02\",\"price\":15,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":15,\"selfPaidAmount\":15},{\"amount\":15,\"chargeItemName\":\"乙肝e抗体测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":15,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":15,\"selfPaidAmount\":15},{\"amount\":6,\"chargeItemName\":\"葡萄糖测定(床边测10539)/次\",\"chargeItemType\":\"FH0173.02\",\"price\":6,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":6,\"selfPaidAmount\":6},{\"amount\":15,\"chargeItemName\":\"乙肝核心抗体测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":15,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":15,\"selfPaidAmount\":15},{\"amount\":9,\"chargeItemName\":\"腺苷脱氨酶测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":9,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":9,\"selfPaidAmount\":9},{\"amount\":30,\"chargeItemName\":\"糖化血红蛋白测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":30,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":30,\"selfPaidAmount\":30},{\"amount\":14,\"chargeItemName\":\"血清载脂蛋白α测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":14,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":14,\"selfPaidAmount\":14},{\"amount\":5,\"chargeItemName\":\"血清总胆汁酸测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":5,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":5,\"selfPaidAmount\":5},{\"amount\":30,\"chargeItemName\":\"梅毒螺旋体特异抗体测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":30,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":30,\"selfPaidAmount\":30},{\"amount\":5,\"chargeItemName\":\"镁测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":5,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":5,\"selfPaidAmount\":5},{\"amount\":12,\"chargeItemName\":\"肾功能常规检查/次\",\"chargeItemType\":\"FH0173.02\",\"price\":12,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":12,\"selfPaidAmount\":12},{\"amount\":10,\"chargeItemName\":\"甘氨酰脯氨酸二肽氨基肽酶测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":10,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":10,\"selfPaidAmount\":10},{\"amount\":5,\"chargeItemName\":\"钙测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":5,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":5,\"selfPaidAmount\":5},{\"amount\":15,\"chargeItemName\":\"乙肝表面抗体测定(Anti-HBs)/项\",\"chargeItemType\":\"FH0173.02\",\"price\":15,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":15,\"selfPaidAmount\":15},{\"amount\":31,\"chargeItemName\":\"肝功能常规检查/次\",\"chargeItemType\":\"FH0173.02\",\"price\":31,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":31,\"selfPaidAmount\":31},{\"amount\":6,\"chargeItemName\":\"血清胆碱脂酶测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":6,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":6,\"selfPaidAmount\":6},{\"amount\":14,\"chargeItemName\":\"超敏C反应蛋白全血快速定量测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":14,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":14,\"selfPaidAmount\":14},{\"amount\":19,\"chargeItemName\":\"血脂常规检查/次\",\"chargeItemType\":\"FH0173.02\",\"price\":19,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":19,\"selfPaidAmount\":19},{\"amount\":8,\"chargeItemName\":\"铁测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":8,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":8,\"selfPaidAmount\":8},{\"amount\":6,\"chargeItemName\":\"葡萄糖测定/次\",\"chargeItemType\":\"FH0173.02\",\"price\":6,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":6,\"selfPaidAmount\":6},{\"amount\":48,\"chargeItemName\":\"凝血功能常规检查/次\",\"chargeItemType\":\"FH0173.02\",\"price\":48,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":48,\"selfPaidAmount\":48},{\"amount\":28,\"chargeItemName\":\"心肌酶谱常规检查/次\",\"chargeItemType\":\"FH0173.02\",\"price\":28,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":28,\"selfPaidAmount\":28},{\"amount\":8,\"chargeItemName\":\"淀粉酶测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":8,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":8,\"selfPaidAmount\":8},{\"amount\":16,\"chargeItemName\":\"人免疫缺陷病毒抗体测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":16,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":16,\"selfPaidAmount\":16},{\"amount\":30,\"chargeItemName\":\"抗甲状腺过氧化物酶抗体测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":30,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":30,\"selfPaidAmount\":30},{\"amount\":90,\"chargeItemName\":\"血清肌钙蛋白Ⅰ测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":90,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":90,\"selfPaidAmount\":90},{\"amount\":48,\"chargeItemName\":\"血同型半胱氨酸测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":48,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":48,\"selfPaidAmount\":48},{\"amount\":10,\"chargeItemName\":\"渗透压检查/项\",\"chargeItemType\":\"FH0173.02\",\"price\":10,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":10,\"selfPaidAmount\":10},{\"amount\":4,\"chargeItemName\":\"卡式配血加收/项\",\"chargeItemType\":\"FH0173.02\",\"price\":4,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":4,\"selfPaidAmount\":4},{\"amount\":1,\"chargeItemName\":\"尿比重测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":1,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":1,\"selfPaidAmount\":1},{\"amount\":5,\"chargeItemName\":\"无机磷测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":5,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":5,\"selfPaidAmount\":5},{\"amount\":8,\"chargeItemName\":\"血清载脂蛋白AⅠ测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":8,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":8,\"selfPaidAmount\":8},{\"amount\":15,\"chargeItemName\":\"丙型肝炎抗体IgG测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":15,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":15,\"selfPaidAmount\":15},{\"amount\":36,\"chargeItemName\":\"血清Ⅳ型胶原测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":36,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":36,\"selfPaidAmount\":36},{\"amount\":6,\"chargeItemName\":\"血清果糖胺测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":6,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":6,\"selfPaidAmount\":6},{\"amount\":15,\"chargeItemName\":\"乙肝e抗原测定(HBeAg)/项\",\"chargeItemType\":\"FH0173.02\",\"price\":15,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":15,\"selfPaidAmount\":15},{\"amount\":8,\"chargeItemName\":\"血清载脂蛋白B测定/项\",\"chargeItemType\":\"FH0173.02\",\"price\":8,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":8,\"selfPaidAmount\":8},{\"amount\":125,\"chargeItemName\":\"甲状腺功能常规检查/次\",\"chargeItemType\":\"FH0173.02\",\"price\":125,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":125,\"selfPaidAmount\":125}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":1263,\"subjectCode\":\"20240122041234\",\"subjectName\":\"实验室诊断费\"},{\"aliasCode\":\"26\",\"amount\":662.8,\"billDetailSummaryWithChargeItem\":[{\"amount\":17.4,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":17.4,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":17.4,\"selfPaidAmount\":17.4},{\"amount\":43,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":21.5,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":43,\"selfPaidAmount\":43},{\"amount\":21,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":21,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":21,\"selfPaidAmount\":21},{\"amount\":61.2,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":10.2,\"quantity\":6,\"selfArrangedAmount\":0,\"selfExpensedAmount\":61.2,\"selfPaidAmount\":61.2},{\"amount\":46,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":23,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":46,\"selfPaidAmount\":46},{\"amount\":20,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":20,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":20,\"selfPaidAmount\":20},{\"amount\":28.3,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":28.3,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":28.3,\"selfPaidAmount\":28.3},{\"amount\":22,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":22,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":22,\"selfPaidAmount\":22},{\"amount\":12.2,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":12.2,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":12.2,\"selfPaidAmount\":12.2},{\"amount\":49.5,\"chargeItemName\":\"伙食/天\",\"chargeItemType\":\"FH0173.02\",\"price\":49.5,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":49.5,\"selfPaidAmount\":49.5},{\"amount\":18,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":18,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":18,\"selfPaidAmount\":18},{\"amount\":47,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":23.5,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":47,\"selfPaidAmount\":47},{\"amount\":25,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":25,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":25,\"selfPaidAmount\":25},{\"amount\":55.5,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":55.5,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":55.5,\"selfPaidAmount\":55.5},{\"amount\":18.5,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":18.5,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":18.5,\"selfPaidAmount\":18.5},{\"amount\":34.2,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":11.4,\"quantity\":3,\"selfArrangedAmount\":0,\"selfExpensedAmount\":34.2,\"selfPaidAmount\":34.2},{\"amount\":144,\"chargeItemName\":\"伙食费\",\"chargeItemType\":\"FH0173.02\",\"price\":24,\"quantity\":6,\"selfArrangedAmount\":0,\"selfExpensedAmount\":144,\"selfPaidAmount\":144}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":662.8,\"subjectCode\":\"20240731303308\",\"subjectName\":\"其他类\"},{\"aliasCode\":\"10.1\",\"amount\":846,\"billDetailSummaryWithChargeItem\":[{\"amount\":88,\"chargeItemName\":\"麻醉中监测（＜4小时）\",\"chargeItemType\":\"FH0173.02\",\"price\":88,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":88,\"selfPaidAmount\":88},{\"amount\":88,\"chargeItemName\":\"术后镇痛/例\",\"chargeItemType\":\"FH0173.02\",\"price\":88,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":88,\"selfPaidAmount\":88},{\"amount\":540,\"chargeItemName\":\"全身麻醉\",\"chargeItemType\":\"FH0173.02\",\"price\":540,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":540,\"selfPaidAmount\":540},{\"amount\":130,\"chargeItemName\":\"麻醉恢复室监护\",\"chargeItemType\":\"FH0173.02\",\"price\":130,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":130,\"selfPaidAmount\":130}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":846,\"subjectCode\":\"20240613151747\",\"subjectName\":\"麻醉费\"},{\"aliasCode\":\"24\",\"amount\":143.4,\"billDetailSummaryWithChargeItem\":[{\"amount\":1.6,\"chargeItemName\":\"真空采血管（蓝色）1.8ml3.2%柠檬酸钠/支\",\"chargeItemType\":\"FH0173.03\",\"price\":0.8,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":1.6,\"selfPaidAmount\":1.6},{\"amount\":5,\"chargeItemName\":\"弹力绷带(II型)10*450/卷\",\"chargeItemType\":\"FH0173.03\",\"price\":2.5,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":5,\"selfPaidAmount\":5},{\"amount\":0.8,\"chargeItemName\":\"真空采血管（绿色）肝素锂3ml/支\",\"chargeItemType\":\"FH0173.03\",\"price\":0.8,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":0.8,\"selfPaidAmount\":0.8},{\"amount\":2.4,\"chargeItemName\":\"真空采血管（紫色）2mlEDTA.K2/支\",\"chargeItemType\":\"FH0173.03\",\"price\":0.8,\"quantity\":3,\"selfArrangedAmount\":0,\"selfExpensedAmount\":2.4,\"selfPaidAmount\":2.4},{\"amount\":1.55,\"chargeItemName\":\"一次性吸氧管(2.0米)/支\",\"chargeItemType\":\"FH0173.03\",\"price\":1.55,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":1.55,\"selfPaidAmount\":1.55},{\"amount\":0.27,\"chargeItemName\":\"静脉采血针（病区）/根\",\"chargeItemType\":\"FH0173.03\",\"price\":0.27,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":0.27,\"selfPaidAmount\":0.27},{\"amount\":0.46,\"chargeItemName\":\"注射器5ml/支\",\"chargeItemType\":\"FH0173.03\",\"price\":0.23,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":0.46,\"selfPaidAmount\":0.46},{\"amount\":92.16,\"chargeItemName\":\"传感器(一次性使用体温)HTB01\",\"chargeItemType\":\"FH0173.03\",\"price\":92.16,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":92.16,\"selfPaidAmount\":92.16},{\"amount\":4.28,\"chargeItemName\":\"灭菌不粘敷贴（25*9）/张\",\"chargeItemType\":\"FH0173.03\",\"price\":2.14,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":4.28,\"selfPaidAmount\":4.28},{\"amount\":32.48,\"chargeItemName\":\"静脉留置针24G Y型/支\",\"chargeItemType\":\"FH0173.03\",\"price\":8.12,\"quantity\":4,\"selfArrangedAmount\":0,\"selfExpensedAmount\":32.48,\"selfPaidAmount\":32.48},{\"amount\":2.4,\"chargeItemName\":\"真空采血管促凝剂5ml（红色）/支\",\"chargeItemType\":\"FH0173.03\",\"price\":0.8,\"quantity\":3,\"selfArrangedAmount\":0,\"selfExpensedAmount\":2.4,\"selfPaidAmount\":2.4}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":143.4,\"subjectCode\":\"20240122344226\",\"subjectName\":\"治疗用一次性医用材料费\"},{\"aliasCode\":\"15\",\"amount\":1096.86,\"billDetailSummaryWithChargeItem\":[{\"amount\":290,\"chargeItemName\":\"(警B)喷他佐辛注射液(跌)/30mg:1ml*1瓶/瓶\",\"chargeItemType\":\"FH0173.01\",\"price\":145,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":290,\"selfPaidAmount\":290},{\"amount\":46.55,\"chargeItemName\":\"0.9%氯化钠注射液（直立软袋）/100ml*1瓶/瓶\",\"chargeItemType\":\"FH0173.01\",\"price\":1.33,\"quantity\":35,\"selfArrangedAmount\":0,\"selfExpensedAmount\":46.55,\"selfPaidAmount\":46.55},{\"amount\":1,\"chargeItemName\":\"0.9%氯化钠注射液/10ml*40支*1盒/支\",\"chargeItemType\":\"FH0173.01\",\"price\":1,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":1,\"selfPaidAmount\":1},{\"amount\":148.08,\"chargeItemName\":\"参芎葡萄糖注射液/50ml*1瓶/瓶\",\"chargeItemType\":\"FH0173.01\",\"price\":24.68,\"quantity\":6,\"selfArrangedAmount\":0,\"selfExpensedAmount\":148.08,\"selfPaidAmount\":148.08},{\"amount\":16.64,\"chargeItemName\":\"(省)地奥司明片/0.45g*24s*1盒/片\",\"chargeItemType\":\"FH0173.01\",\"price\":0.6375,\"quantity\":26,\"selfArrangedAmount\":0,\"selfExpensedAmount\":16.64,\"selfPaidAmount\":16.64},{\"amount\":10.24,\"chargeItemName\":\"(集)(中美)泮托拉唑钠针（重）/40mg*1支/支\",\"chargeItemType\":\"FH0173.01\",\"price\":2.56,\"quantity\":4,\"selfArrangedAmount\":0,\"selfExpensedAmount\":10.24,\"selfPaidAmount\":10.24},{\"amount\":45,\"chargeItemName\":\"盐酸雷尼替丁注射液/2ml:50mg*1支/支\",\"chargeItemType\":\"FH0173.01\",\"price\":45,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":45,\"selfPaidAmount\":45},{\"amount\":56.8,\"chargeItemName\":\"(跌)甘露醇注射液(软袋)/20g:100ml*1袋/袋\",\"chargeItemType\":\"FH0173.01\",\"price\":7.1,\"quantity\":8,\"selfArrangedAmount\":0,\"selfExpensedAmount\":56.8,\"selfPaidAmount\":56.8},{\"amount\":8.64,\"chargeItemName\":\"甲磺酸倍他司汀片（重）/6mg*100片*1盒/片\",\"chargeItemType\":\"FH0173.01\",\"price\":0.3602,\"quantity\":24,\"selfArrangedAmount\":0,\"selfExpensedAmount\":8.64,\"selfPaidAmount\":8.64},{\"amount\":1.98,\"chargeItemName\":\"甲氧氯普胺针(灭吐灵针)/10mg:1ml*10支/支\",\"chargeItemType\":\"FH0173.01\",\"price\":1.98,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":1.98,\"selfPaidAmount\":1.98},{\"amount\":2.23,\"chargeItemName\":\"集(警A)利多卡因注射液(跌)/0.1g:5ml*1支/支\",\"chargeItemType\":\"FH0173.01\",\"price\":2.23,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":2.23,\"selfPaidAmount\":2.23},{\"amount\":6.96,\"chargeItemName\":\"复方氯化钠注射液（双管双阀）/500ml*1瓶/瓶\",\"chargeItemType\":\"FH0173.01\",\"price\":3.48,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":6.96,\"selfPaidAmount\":6.96},{\"amount\":1.69,\"chargeItemName\":\"(警B)异丙嗪针(跌)/25mg:1ml*10支/支\",\"chargeItemType\":\"FH0173.01\",\"price\":1.69,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":1.69,\"selfPaidAmount\":1.69},{\"amount\":9.96,\"chargeItemName\":\"(省)(0.2g)天麻素注射液/0.2g:2ml*1支/支\",\"chargeItemType\":\"FH0173.01\",\"price\":0.83,\"quantity\":12,\"selfArrangedAmount\":0,\"selfExpensedAmount\":9.96,\"selfPaidAmount\":9.96},{\"amount\":1.41,\"chargeItemName\":\"(集)(贝奇康)硝苯地平控释片(跌)/30mg*21片*1盒/片\",\"chargeItemType\":\"FH0173.01\",\"price\":0.4743,\"quantity\":3,\"selfArrangedAmount\":0,\"selfExpensedAmount\":1.41,\"selfPaidAmount\":1.41},{\"amount\":7.75,\"chargeItemName\":\"0.9%氯化钠注射液（直立软袋）/250ml*1瓶/瓶\",\"chargeItemType\":\"FH0173.01\",\"price\":1.55,\"quantity\":5,\"selfArrangedAmount\":0,\"selfExpensedAmount\":7.75,\"selfPaidAmount\":7.75},{\"amount\":22.16,\"chargeItemName\":\"(警C)(可定)瑞舒伐他汀钙片/10mg*7片/片\",\"chargeItemType\":\"FH0173.01\",\"price\":5.5429,\"quantity\":4,\"selfArrangedAmount\":0,\"selfExpensedAmount\":22.16,\"selfPaidAmount\":22.16},{\"amount\":1.19,\"chargeItemName\":\"(集)(妥立士宁)盐酸托烷司琼注射液/5mg:5ml*1支/支\",\"chargeItemType\":\"FH0173.01\",\"price\":1.19,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":1.19,\"selfPaidAmount\":1.19},{\"amount\":78.54,\"chargeItemName\":\"(集)酮咯酸氨丁三醇注射液/1ml:30mg*1支/支\",\"chargeItemType\":\"FH0173.01\",\"price\":3.57,\"quantity\":22,\"selfArrangedAmount\":0,\"selfExpensedAmount\":78.54,\"selfPaidAmount\":78.54},{\"amount\":178,\"chargeItemName\":\"盐酸纳布啡注射液/10mg:1ml*1支/支\",\"chargeItemType\":\"FH0173.01\",\"price\":89,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":178,\"selfPaidAmount\":178},{\"amount\":1.32,\"chargeItemName\":\"酒石酸托特罗定片（贝可）/2mg*14片/片\",\"chargeItemType\":\"FH0173.01\",\"price\":1.32,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":1.32,\"selfPaidAmount\":1.32},{\"amount\":160.72,\"chargeItemName\":\"(警B)(省)达肝素钠针/5000IU:0.2ml*2支*1盒/支\",\"chargeItemType\":\"FH0173.01\",\"price\":11.48,\"quantity\":14,\"selfArrangedAmount\":0,\"selfExpensedAmount\":160.72,\"selfPaidAmount\":160.72}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":1096.86,\"subjectCode\":\"20240122101277\",\"subjectName\":\"西药费\"},{\"aliasCode\":\"13\",\"amount\":545,\"billDetailSummaryWithChargeItem\":[{\"amount\":176,\"chargeItemName\":\"穴位贴敷治疗/穴位\",\"chargeItemType\":\"FH0173.02\",\"price\":8,\"quantity\":22,\"selfArrangedAmount\":0,\"selfExpensedAmount\":176,\"selfPaidAmount\":176},{\"amount\":-41,\"chargeItemName\":\"隔物灸法(隔盐灸)/人次 (100.00%)\",\"chargeItemType\":\"FH0173.02\",\"price\":41,\"quantity\":-1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":-41,\"selfPaidAmount\":-41},{\"amount\":410,\"chargeItemName\":\"隔物灸法(隔盐灸)/人次\",\"chargeItemType\":\"FH0173.02\",\"price\":41,\"quantity\":10,\"selfArrangedAmount\":0,\"selfExpensedAmount\":410,\"selfPaidAmount\":410}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":545,\"subjectCode\":\"20240122400022\",\"subjectName\":\"中医治疗费\"},{\"aliasCode\":\"2\",\"amount\":653.1,\"billDetailSummaryWithChargeItem\":[{\"amount\":224.4,\"chargeItemName\":\"静脉输液（住院/含输液器）/床日\",\"chargeItemType\":\"FH0173.02\",\"price\":18.7,\"quantity\":12,\"selfArrangedAmount\":0,\"selfExpensedAmount\":224.4,\"selfPaidAmount\":224.4},{\"amount\":80,\"chargeItemName\":\"静脉穿刺置管术/次\",\"chargeItemType\":\"FH0173.02\",\"price\":20,\"quantity\":4,\"selfArrangedAmount\":0,\"selfExpensedAmount\":80,\"selfPaidAmount\":80},{\"amount\":37.7,\"chargeItemName\":\"皮下注射/次\",\"chargeItemType\":\"FH0173.02\",\"price\":2.9,\"quantity\":13,\"selfArrangedAmount\":0,\"selfExpensedAmount\":37.7,\"selfPaidAmount\":37.7},{\"amount\":105,\"chargeItemName\":\"鼻导管吸氧/小时\",\"chargeItemType\":\"FH0173.02\",\"price\":5,\"quantity\":21,\"selfArrangedAmount\":0,\"selfExpensedAmount\":105,\"selfPaidAmount\":105},{\"amount\":5.8,\"chargeItemName\":\"静脉采血(病区)/次\",\"chargeItemType\":\"FH0173.02\",\"price\":5.8,\"quantity\":1,\"selfArrangedAmount\":0,\"selfExpensedAmount\":5.8,\"selfPaidAmount\":5.8},{\"amount\":93.6,\"chargeItemName\":\"静脉置管冲洗/日\",\"chargeItemType\":\"FH0173.02\",\"price\":7.8,\"quantity\":12,\"selfArrangedAmount\":0,\"selfExpensedAmount\":93.6,\"selfPaidAmount\":93.6},{\"amount\":80,\"chargeItemName\":\"大换药/次\",\"chargeItemType\":\"FH0173.02\",\"price\":40,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":80,\"selfPaidAmount\":80},{\"amount\":20.8,\"chargeItemName\":\"术后引流/次\",\"chargeItemType\":\"FH0173.02\",\"price\":10.4,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":20.8,\"selfPaidAmount\":20.8},{\"amount\":5.8,\"chargeItemName\":\"肌肉注射/次\",\"chargeItemType\":\"FH0173.02\",\"price\":2.9,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":5.8,\"selfPaidAmount\":5.8}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":653.1,\"subjectCode\":\"20240122813731\",\"subjectName\":\"一般治疗操作费\"},{\"aliasCode\":\"9.1\",\"amount\":132,\"billDetailSummaryWithChargeItem\":[{\"amount\":132,\"chargeItemName\":\"超声药物透入治疗/人次\",\"chargeItemType\":\"FH0173.02\",\"price\":66,\"quantity\":2,\"selfArrangedAmount\":0,\"selfExpensedAmount\":132,\"selfPaidAmount\":132}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":132,\"subjectCode\":\"20240613386854\",\"subjectName\":\"临床物理治疗\"},{\"aliasCode\":\"15.1\",\"amount\":421.12,\"billDetailSummaryWithChargeItem\":[{\"amount\":421.12,\"chargeItemName\":\"(集)(0.5g)头孢美唑钠针/0.5g*1瓶/瓶\",\"chargeItemType\":\"FH0173.01\",\"price\":13.16,\"quantity\":32,\"selfArrangedAmount\":0,\"selfExpensedAmount\":421.12,\"selfPaidAmount\":421.12}],\"discountAmount\":0,\"selfArrangedAmount\":0,\"selfExpensedAmount\":421.12,\"subjectCode\":\"20240613164402\",\"subjectName\":\"抗菌药物费\"}]";
        return JSONArray.parseArray(string, BillDetailSummaryWithSubjectDTO.class);
    }


    /*从原始病案首页筛选出非割接费用*/
    public static  List<BillDetailSummaryWithSubjectDTO> listOriginalBillDetailSummaryWithoutTransfer(
            List<BillDetailSummaryWithSubjectDTO> billDetailSummaryWithSubject) {
        //割接费用的chargeItemCode
        List<String> chargeItemCodeList = Arrays.asList("9999999991", "9999999990", "9999999993", "9999999992");
        //移除原始病案首页的割接费用
        List<BillDetailSummaryWithSubjectDTO> newBillDetailSummaryWithSubject = new ArrayList<>();
        //循环开始
        for (BillDetailSummaryWithSubjectDTO summaryWithSubjectDTO : billDetailSummaryWithSubject) {
            //明细包含割接费用明细
            List<BillDetailSummaryWithChargeItemDTO> detailsContainsTransfer = summaryWithSubjectDTO.getBillDetailSummaryWithChargeItem().stream()
                    .filter(item -> chargeItemCodeList.contains(item.getChargeItemCode())).collect(Collectors.toList());
            //不包含割接明细直接添加
            if (CollectionUtils.isEmpty(detailsContainsTransfer)) {
                newBillDetailSummaryWithSubject.add(summaryWithSubjectDTO);
                continue;
            }
            //移除割接费用后
            List<BillDetailSummaryWithChargeItemDTO> details_noTransfer = summaryWithSubjectDTO.getBillDetailSummaryWithChargeItem().stream()
                    .filter(item -> !chargeItemCodeList.contains(item.getChargeItemCode())).collect(Collectors.toList());
            //移除割接费用后,不存在其他费用直接移除
            if (CollectionUtils.isEmpty(details_noTransfer)) {
                continue;
            }
            //存在非割接费用
            BigDecimal noTransferAmount = details_noTransfer.stream().map(BillDetailSummaryWithChargeItemDTO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
            BigDecimal noTransferArrangedAmount = details_noTransfer.stream().map(BillDetailSummaryWithChargeItemDTO::getSelfArrangedAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
            BigDecimal noTransferSelfExpensedAmount = details_noTransfer.stream().map(BillDetailSummaryWithChargeItemDTO::getSelfExpensedAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
            summaryWithSubjectDTO.setAmount(noTransferAmount);
            summaryWithSubjectDTO.setSelfArrangedAmount(noTransferArrangedAmount);
            summaryWithSubjectDTO.setSelfExpensedAmount(noTransferSelfExpensedAmount);
            summaryWithSubjectDTO.setBillDetailSummaryWithChargeItem(details_noTransfer);
            newBillDetailSummaryWithSubject.add(summaryWithSubjectDTO);
        }
        return newBillDetailSummaryWithSubject;
    }











    public static List<String> getSameBizSubjectCodeBetweenTransferAndOriginal(List<BillDetailSummaryWithSubjectDTO> originalBillDetailSummary_noTransfer,
                                                                               List<BillDetailSummaryWithSubjectDTO> transferSummaryWithSubject) {
        Set<String> originalSubjectCodes = originalBillDetailSummary_noTransfer.stream()
                .map(BillDetailSummaryWithSubjectDTO::getSubjectCode)
                .collect(Collectors.toSet());
        return transferSummaryWithSubject.stream()
                .filter(item -> originalSubjectCodes.contains(item.getSubjectCode()))
                .map(BillDetailSummaryWithSubjectDTO::getSubjectCode).distinct()
                .collect(Collectors.toList());
    }

}
